﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using COM.OA.BLL;
using COM.OA.Entity;


public partial class rc_jh_employeeplan : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Response.Write("<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr><td width='6' height='21'><img src='../images/sj/leftlin1.gif' width='6' height='21'></td><td width='936' bgcolor='#5AAE18'><div align='center'><div align='center' class='style1'><span class='style3 style2 style1 style16'><strong>部 门 计 划 </strong></span></div><span class='style1'></span></div></td><td width='6' height='21'><img src='../images/sj/rightlin1.gif' width='6' height='21'></td></tr></table>");

        //取出所有部门
        IList<department> deptList = departmentBLL.Select();
        if (deptList.Count != 0)
        {
            this.Response.Write("<table width='100%' border='0' cellpadding='2' cellspacing='1' bgcolor='#5AAE18'><tr><td bgcolor='#FFFFFF'>");
            foreach (department d in deptList)
            {
                this.Response.Write("<a href='jh_deptplan.aspx?dept=" + d.dept_id + "'>" + d.dept_department + "</a>&nbsp;&nbsp;");
            }
            this.Response.Write("</td></tr></table>");
        }

        this.Response.Write("<table width='200' border='0' cellspacing='0' cellpadding='0'><tr><td>&nbsp;</td></tr></table>");

        int to_u_id = 0;
        int deptvalue;
        if (!Page.IsPostBack)
        {
            deptvalue = 1;
        }
        else
        {
            deptvalue = Int32.Parse(this.Request.QueryString["dept"]);
        }
        string sql2 = "u_dept_id='{0}'";
        sql2 = string.Format(sql2, deptvalue);
        IList<users> userList = usersBLL.Select(sql2);
        if (userList.Count != 0)
        {
            foreach (users user in userList)
            {
                to_u_id = user.u_id;
            }
        }

        string sql = "to_u_id='{0}' and to_state='1'";
        sql = string.Format(sql, to_u_id);
        IList<timeorder> tolist = timeorderBLL.Select(sql,true,false);
        if (tolist.Count != 0)
        {
            this.Response.Write("<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr><td width='6' height='21'><img src='../images/sj/leftlin1.gif' width='6' height='21'></td><td width='936' bgcolor='#5AAE18'><div align='center'><div align='center' class='style1'><span class='style3 style2 style1 style16'><strong>计 划 列 表</strong></span></div><span class='style1'></span></div></td><td width='6' height='21'><img src='../images/sj/rightlin1.gif' width='6' height='21'></td></tr></table>");
            this.Response.Write("<table width='100%' border='0' cellpadding='2' cellspacing='1' bgcolor='#5AAE18'>");
            foreach (timeorder t in tolist)
            {
                int deptid = t.users.u_dept_id;
                string dept = "";
                string sql3 = "dept_id='{0}'";
                sql3 = string.Format(sql3, deptid);
                IList<department> deptlist = departmentBLL.Select(sql3);
                if (deptlist.Count == 1)
                {
                    foreach (department d in deptlist)
                    {
                        dept = d.dept_department;
                    }
                }
                string cont = t.to_content;
                if (cont.Length > 40)
                {
                    cont = cont.Substring(0, 40) + ".............";
                }
                int userid = t.users.u_em_id;
                string emname="";
                string sql4 = "em_id='{0}'";
                sql4 = string.Format(sql4, userid);
                IList<employee> emlist = employeeBLL.Select(sql4);
                if (emlist.Count == 1)
                {
                    foreach (employee empl in emlist)
                    {
                        emname = empl.em_name;
                    }
                }
                this.Response.Write("<tr bgcolor='#E9F3D6'><td width='36'><span class='style14 style17'>标 题</span></td>");
                this.Response.Write("<td><span class='style10'>" + t.to_title + "<span class='style8 style15'><span class='style1 style17'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + emname + "<span class='style20'><span class='style17'><span class='style15'><strong>&nbsp;&nbsp;<img src='../images/sj/write1.gif' width='13' height='7'> </strong></span></span></span></span></span></span></td></tr>");
                this.Response.Write("<tr bgcolor='#FFFFFF'><td width='36' valign='top'><span class='style14 style17'>内 容</span></td><td width='718' class='style3' style='word-break:break-all;Width:fixed'>"+cont+"</td></tr>");
                this.Response.Write("<tr bgcolor='#FFFFFF'><td>&nbsp;</td><td><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td width='15%'><span class='style1 style17'><strong><strong><span class='style17'>&nbsp;&nbsp;&nbsp;&nbsp;<img src='../images/sj/write.gif' width='7' height='13'> </span></strong></strong>发送人</span><span class='style14 style17'>:</span><span class='style1 style17'>" + emname + "</span></td><td width='16%'><span class='style1 style17'>部门:" + dept + "</span></td><td width='69%'><span class='style1 style17'><span class='style17'>时间:" + t.to_sendtime + "</span></span></td></tr></table></td></tr>");
            }
           
            this.Response.Write("</table>");
            this.Response.Write("<div align='center'><p class='style17'> (总共" + tolist.Count.ToString() + "条记录)<br><img alt=''  src='../images/sj/up.gif' width='17' height='12'/><a href='javascript:history.go(-1)'>返回</a></p></div>");
        }       
    }
}
